﻿<Window x:Class="TreeView_binding.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:TreeView_binding"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TreeView Height="208" HorizontalAlignment="Left" Margin="12,12,0,0" Name="treeView1" VerticalAlignment="Top" Width="317" 
         ItemsSource="{Binding Path=Tree}">
            <TreeView.Resources>
                <HierarchicalDataTemplate DataType="{x:Type local:InnerNode}" ItemsSource="{Binding Path=Children}">
                    <TextBlock Text="{Binding Path=Label}"/>
                </HierarchicalDataTemplate>
                <DataTemplate DataType="{x:Type local:LeafNode}">
                    <TextBlock Text="{Binding Path=Label}" Foreground="Red"/>
                </DataTemplate>
            </TreeView.Resources>
        </TreeView>
        <TextBox Height="24" HorizontalAlignment="Left" Margin="12,226,0,0" Name="textBox1" VerticalAlignment="Top" Width="121" />
        <Button Content="Add Inner" Height="24" HorizontalAlignment="Right" Margin="0,226,272,0" Name="button1" VerticalAlignment="Top" Width="92" Click="button1_Click" />
        <Button Content="Add Leaf" Height="24" HorizontalAlignment="Right" Margin="0,226,174,0" Name="button2" VerticalAlignment="Top" Width="92" Click="button2_Click" />
    </Grid>
</Window>
